package sip

import (
	"strings"
)

// URI (Uniform Resource Indicators)
// sip:user:password@host:port;uri-parameters?headers
// RFC 3261, 19.1
type URI struct {
	Scheme     string // "sip:" or "sips:"
	User       string
	Password   string
	Host       string
	Port       int
	Parameters map[string]string
	Headers    map[string]string
}

// String
func (u *URI) String() string {
	var sb strings.Builder
	sb.WriteString(u.Scheme)
	sb.WriteString(u.User)
	sb.WriteString(u.Password)
	sb.WriteString("@")
	sb.WriteString(u.Host)
	return sb.String()
}

// AreEqual ...
func (u *URI) AreEqual(uri URI) bool {
	return u.String() == uri.String()
}
